import { useEffect } from 'react'
import settings from '@/config/settings'

const useTitle = (title?: string): void => {
  const setTitle = (name: string): void => {
    document.title = `${name} - ${settings.siteTitle}`
  }

  useEffect(() => {
    setTitle(title || '')
  }, [title])
}

export default useTitle
